#include <bits/stdc++.h>
// 2025/07/20
// tag:
// Author: Forever
using namespace std;
using int64 = int64_t;

int n, tmax, d[10001];

bool check(int mid)
{
    priority_queue<int, vector<int>, greater<int>> q;
    for (int i = 1; i <= mid; i++)
        q.push(d[i]);
    int last = 0, cnt = mid;
    while (!q.empty()) {
        int x = q.top();
        q.pop();
        if (x > tmax)
            return false;
        last = x;
        if (cnt < n)
            q.push(d[++cnt] + last);
    }
    return true;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> tmax;
    for (int i = 1; i <= n; i++)
        cin >> d[i];
    int l = 1, r = n;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid))
            r = mid - 1;
        else
            l = mid + 1;
    }
    cout << l << endl;
    return 0;
}